package com.bdqn.mapper;

import com.bdqn.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from sys_user where user_name=#{userName} and password=#{password} and status=1")
    User selectUser(@Param("userName") String userName,@Param("password") String password);

    @Select("select * from sys_user")
    List<User> getAll();
    List<User> selectAll(String name);

    @Insert("insert into sys_user values(NULL,#{userName},#{password},#{status},#{picture})")
    int add(User user);

    int addRoles(@Param("uid") Integer uid,@Param("rids")  List<Integer> rids);

    @Update("update sys_user set status=#{status} where user_id=#{uid}")
    int updateStatus(@Param("uid") int userId,@Param("status") String status);

    @Select("select * from sys_user where user_id=#{userId}")
    User selectById(int uid);

    @Delete("delete from sys_role_user where user_id=#{uid}")
    void deleteRole(Integer uid);

    @Update("update sys_user set user_name=#{userName},password=#{password},status=#{status},picture=#{picture} where user_id=#{userId}")
    int updateUser(User user);

    @Delete("delete from sys_user where user_id=#{userId}")
    int deleteUser(int id);
}
